package com.example.smartlearning.controller;

import com.example.smartlearning.service.impl.QuanZiServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@CrossOrigin//跨域
@RestController//遵循RestFul
@RequestMapping("/Smart/QuanZi/")
public class QuanZiController {

    @Resource
    QuanZiServiceImpl quanZiService;

    /**
     * 获取所有圈子接口
     *
     * @return 返回结果
     */
    @GetMapping("getAll")
    public String getAll() {
        return quanZiService.getAll();
    }

    /**
     * 查询用户加入的圈子
     *
     * @param id 用户id
     * @return 返回
     */
    @GetMapping("getAllById")
    public String getAllById(@RequestParam("id") int id) {
        return quanZiService.getAllById(id);
    }

    /**
     * 加入新的圈子
     *
     * @param userId   用户id
     * @param quanZiId 圈子id
     * @return 返回
     */
    @PostMapping("addNew")
    public String addNew(@RequestParam("userId") int userId, @RequestParam("quanZiId") int quanZiId) {
        return quanZiService.addNew(userId, quanZiId);
    }

    /**
     * 根据圈子id获取所有的互动话题
     * @param topicId 圈子id
     * @return 返回
     */
    @GetMapping("getTopic")
    public String getTopic(@RequestParam("topicId") int topicId) {
        return quanZiService.getTopic(topicId);
    }


}
